package com.syx.friend.Controller.exam;

import com.syx.commoncore.Model.Result;
import com.syx.commoncore.Model.TableDataInfoResult;
import com.syx.friend.Aop.CheckUserStatus;
import com.syx.friend.Model.exam.DTO.ExamQueryDTO;
import com.syx.friend.Model.exam.DTO.ExamRankDTO;
import com.syx.friend.Service.IExamService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/exam")
public class ExamController {

    @Resource
    IExamService iExamService;



    //redis
    @GetMapping("/semiLogin/list")
    public TableDataInfoResult list(ExamQueryDTO examQueryDTO) {
        return iExamService.list(examQueryDTO);
    }

    @GetMapping("/semiLogin/redis/list")
    public TableDataInfoResult redisList(ExamQueryDTO examQueryDTO){

        return iExamService.redisList(examQueryDTO);

    }
    //获取题目详情接口，开始答题，对题目进行排序通过key-》q:l

    //点击竞赛返回第一个题目id
    @CheckUserStatus
    @GetMapping("/getFirstQuestion")
    public Result<String> getFirstQuestion(Long examId){
        //获取所有的对应的该竞赛的列表，将所有的questionId存储在redis中
        return iExamService.getFirstQuestion(examId);
    }

    @CheckUserStatus
    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long examId,Long questionId){
        //返回上一题的题目Id
        return iExamService.preQuestion(examId,questionId);


    }
    @CheckUserStatus
    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long examId,Long questionId){
        //返回下一题的题目Id
        return iExamService.nextQuestion(examId,questionId);



    }

    @GetMapping("/rank/list")
    public TableDataInfoResult rankList(ExamRankDTO examRankDTO) {
        return iExamService.rankList(examRankDTO);
    }








}
